﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NCAB.WF
{
    public partial class User_Create : System.Web.UI.Page
    {
        private MembershipUser user;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());
            }

            if (Request.IsAuthenticated && Membership.GetUser() != null)
            {
                user = Membership.GetUser();
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        }

        void Page_PreRender(object obj, EventArgs e)
        {
            ViewState["update"] = Session["update"];
        }

        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            try
            {
                aspnet_UserExtraInfo user = new aspnet_UserExtraInfo();
                user.Nombres = txtFirstName.Text;
                user.Apellidos = txtLastName.Text;
                user.Identificacion = txtIdentification.Text;
                user.TMovil = txtMobile.Text;
                user.TOficina = txtOffice.Text;
                user.Email = txtEmail.Text;
                user.NombreUsuario = txtUserName.Text;
                user.Direccion = txtAddress.Text;

                services.WS_User ws = new services.WS_User();
                string respuesta = ws.CreateUser(user);
                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}